package com.sensePlusVR.utils;

import android.content.Context;
import android.util.Log;

/**
 * 
 * @author: Loren
 * @create: 2016-7-1上午10:34:15
 * @desc: 
 * http://blog.csdn.net/jansin_love/article/details/9163353
 * 
 * LOG_LEVEL = 6 输出Log
 * LOG_LEVEL = 0 不输出Log
 *
 */
public class MyLog {
	public static int LOG_LEVEL = 6;
	public static int ERROR = 1;
	public static int WARN = 2;
	public static int INFO = 3;
	public static int DEBUG = 4;
	public static int VERBOS = 5;

	
	/**
	 * 检查log
	 * @param context
	 */
	public static void checkLog(Context context){
		boolean isFileExist = FileUtils.isFileExist(FileUtils.getSDcardDir() + Constant.PATH_ANDROID_LOG);
		LOG_LEVEL = isFileExist?VERBOS+1:ERROR-1;
		if(isFileExist){
			MyLogUtil.getInstance(context).start();
		}
	}


	public static void e(String tag, String msg) {
		if (LOG_LEVEL > ERROR)
			Log.e(tag, msg);
	}

	public static void e(String tag, String msg, Throwable tr) {
		if (LOG_LEVEL > ERROR)
			Log.e(tag, msg, tr);
	}

	public static void w(String tag, String msg) {
		if (LOG_LEVEL > WARN)
			Log.w(tag, msg);
	}

	public static void w(String tag, String msg, Throwable tr) {
		if (LOG_LEVEL > WARN)
			Log.w(tag, msg, tr);
	}

	public static void i(String tag, String msg) {
		if (LOG_LEVEL > INFO)
			Log.i(tag, msg);
	}

	public static void i(String tag, String msg, Throwable tr) {
		if (LOG_LEVEL > INFO)
			Log.i(tag, msg, tr);
	}

	public static void d(String tag, String msg) {
		if (LOG_LEVEL > DEBUG)
			Log.d(tag, msg);

	}

	public static void d(String tag, String msg, Throwable tr) {
		if (LOG_LEVEL > DEBUG)
			Log.d(tag, msg, tr);
	}

	public static void v(String tag, String msg) {
		if (LOG_LEVEL > VERBOS)
			Log.v(tag, msg);
	}

	public static void v(String tag, String msg, Throwable tr) {
		if (LOG_LEVEL > VERBOS)
			Log.v(tag, msg, tr);
	}
	
	
}
